package shap03;

/**
 * @author Administrator
 * 类由属性和方法组成：成员变量和
 */
public class Person {
    //封装：1）属性前加private修饰，2)setter,getter方法设置和获取属性值
   private String name;
   private int age;

   /*构造方法*/
   Person(){

   }
   Person(String name){
     this.name=name;
   }
   Person(String name,int age){
     this.name=name;
     this.age=age;
   }








  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  void eat(){
        System.out.println(name+"喜欢吃饭");
    }
    void speak(){
        System.out.println(name+"喜欢说话");
    }
    void hobby() {
        System.out.println(name + "不太喜欢打代码");
    }
}


